package.cpath = package.cpath .. ';C:/Users/win/AppData/Roaming/JetBrains/IdeaIC2020.3/plugins/intellij-emmylua/classes/debugger/emmy/windows/x86/?.dll'
local dbg = require('emmy_core')
dbg.tcpConnect('localhost', 9966)

package.path = package.path .. ";C:/Users/win/Documents/_lua/util/?.lua"

local SkipList = require("SkipList")

math.randomseed(os.time())

function Test1()
    local list = SkipList.new(function(a, b)
        return a - b
    end)
    assert(0 == list:GetCount())
    assert(false == list:Contains(1))

    local arr = { 1, 6, 9, 3, 5, 7, 4, 8}
    for i=1,#arr do
        local item = arr[i]
        list:Add(item, "a"..item)
        assert(i == list:GetCount())
        assert(true == list:Contains(item))
    end
    print(tostring(list))

    for i=1,#arr do
        local item = arr[i]
        assert(true == list:Remove(item))
        assert(#arr-i == list:GetCount())
        assert(false == list:Contains(item))
        print(tostring(list))
    end
    assert(0 == list:GetCount())
end
Test1()

